#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/12/28 21:02
# @Author  : micah
# @File    : 1.使用python获取百度首页信息.py
# @Software: PyCharm


import requests

headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
}


response = requests.get('https://www.baidu.com', headers=headers)
print(response.text)  # 百度服务器的网页源代码 有些可能是乱码
print(response.content.decode('utf-8'))  # 在里面输入编码格式就不会出现乱码






